﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MaLu.Common;
using MaLu.BusiLogic;
using System.Data;

namespace MaluJg.web.Three
{
    public partial class T2Detail : ThreePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "走村入户详情";
            this.UseTabber = true;
            if (!IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            int status = (int)MaLu.Common.Const.EventStatus.已提交;

            if (EventID != Guid.Empty)
            {

                DataSet ds = BLThree.GetEvent2(Provider, EventID);
                if (ds.Tables.Count >= 2)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        Title = "走村入户详情编辑";
                        DataRow drInfo = ds.Tables[0].Rows[0];
                        status = int.Parse(drInfo["Status"].ToString());
                        lbDept.Text = drInfo["DeptDspName"].ToString();
                        lbSign.Text = drInfo["Signature"].ToString();

                        lbDate.Text = drInfo["year"].ToString() + "年" + drInfo["month"].ToString() + "月" +
                            drInfo["day"].ToString() + "日";


                    }

                    DataTable dtIns = ds.Tables[1];
                    rpInstance.DataSource = dtIns;
                    rpInstance.DataBind();
                }
            }
            
            if (status == (int)MaLu.Common.Const.EventStatus.已审阅)
            {
                tdEdit.Visible = false;
               

            }
         
        }
        protected void lbtnDelete_Click(object sender, EventArgs e)
        {
            int result = 0;

            string alert = "已删除！";


            result = BLThree.DeleteEvent2(Provider, EventID == Guid.Empty ? Guid.NewGuid() : EventID);

            if (result == 1)
            {
                alert = "已审阅,不能删除！";

            }
            if (result == 0)

                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "save", "<script>alert('" + alert + "');window.parent.location.href=window.parent.location.href;</script>");
            if (result == 1)

                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "save", "<script>alert('" + alert + "');location=location;</script>");

        }
        protected Guid EventID
        {
            get
            {
                Guid gd = Guid.Empty;
                try
                {
                    gd = new Guid(Request["EventID"] ?? Guid.Empty.ToString());

                }
                catch { }

                return gd;

            }
        }
    }
}
